/*
 *
 * NDbUnit
 * Copyright (C)2005 - 2010
 * http://code.google.com/p/ndbunit
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 */

using System;
using System.Collections.Specialized;
using System.Data;
using System.IO;

namespace NDbUnit.Core
{
    /// <summary>
    /// Represents a unit test database initialization operation.
    /// </summary>
    public interface INDbUnitTest
    {
        /// <summary>
        /// Occurs after DbOperation has completed.
        /// </summary>
        event PostOperationEvent PostOperation;

        /// <summary>
        /// Occurs before DbOperation begins.
        /// </summary>
        event PreOperationEvent PreOperation;

        /// <summary>
        /// Performs a database operation.
        /// </summary>
        /// <param name="dbOperationFlag">The database operation to perform.</param>
        /// <exception cref="NDbUnitException" />
        void PerformDbOperation(DbOperationFlag dbOperationFlag);

        /// <summary>
        /// Read in an xml schema file whose schema represents a set of
        /// tables in a database.  This schema file is used to build the
        /// database modification commands that are used to update the 
        /// database.  This is the first function that must be called 
        /// prior to any other functions being called on the interface.  
        /// Otherwise, an exception will be thrown.
        /// </summary>
        /// <remarks>The xml schema file can be generated by dragging and 
        /// dropping tables from Visual Studio's server explorer into a 
        /// DataSet.xsd file.</remarks>
        /// <param name="xmlSchemaFile">The schema file.</param>
        /// <exception cref="ArgumentException" />
        void ReadXmlSchema(string xmlSchemaFile);

        /// <summary>
        /// Read in an xml schema whose schema represents a set of
        /// tables in a database.  This schema is used to build the
        /// database modification commands that are used to update the 
        /// database.  This is the first function that must be called 
        /// prior to any other functions being called on the interface.  
        /// Otherwise, an exception will be thrown.
        /// </summary>
        /// <param name="xmlSchema">The schema stream.</param>
        /// <exception cref="ArgumentException" />
        void ReadXmlSchema(Stream xmlSchema);

        /// <summary>
        /// Read in an xml file whose data should be conform to the schema 
        /// of the file specified in the call to <see cref="ReadXmlSchema" />.  
        /// If the data does not conform to the schema, it will be ignored.  
        /// This data is used to update the database.
        /// </summary>
        /// <param name="xmlFile">The xml file.</param>
        /// <exception cref="ArgumentException" />
        void ReadXml(string xmlFile);

        /// <summary>
        /// Read in an xml stream whose data should be conform to the schema 
        /// specified in the call to <see cref="ReadXmlSchema" />.  
        /// If the data does not conform to the schema, it will be ignored.  
        /// This data is used to update the database.
        /// </summary>
        /// <param name="xml">The xml stream.</param>
        /// <exception cref="ArgumentException" />
        void ReadXml(Stream xml);

        /// <summary>
        /// Read in an xml file whose data should be conform to the schema 
        /// of the file specified in the call to <see cref="ReadXmlSchema" />.  
        /// The data is appended to any existing data in the dataset.
        /// If the data does not conform to the schema, it will be ignored.  
        /// This data is used to update the database.
        /// </summary>
        /// <param name="xmlFile">The xml file.</param>
        /// <exception cref="ArgumentException" />
        void AppendXml(string xmlFile);

        /// <summary>
        /// Read in an xml stream whose data should be conform to the schema 
        /// specified in the call to <see cref="ReadXmlSchema" />.
        /// The data is appended to any existing data in the dataset.
        /// If the data does not conform to the schema, it will be ignored.  
        /// This data is used to update the database.
        /// </summary>
        /// <param name="xml">The xml stream.</param>
        /// <exception cref="ArgumentException" />
        void AppendXml(Stream xml);

        /// <summary>
        /// Gets a <see cref="DataSet" /> object that contains both the 
        /// internal schema information and data.
        /// </summary>
        /// <returns><see cref="DataSet" /></returns>
        /// <exception cref="NDbUnitException" />
        DataSet CopyDataSet();

        /// <summary>
        /// Gets a <see cref="DataSet" /> object that contains only the 
        /// internal schema information.
        /// </summary>
        /// <returns><see cref="DataSet" /></returns>
        /// <exception cref="NDbUnitException" />
        DataSet CopySchema();

        /// <summary>
        /// Gets a data set from the database tables.  Includes all
        /// table names in the xml schema.
        /// </summary>
        /// <exception cref="NDbUnitException" />
        DataSet GetDataSetFromDb();

        /// <summary>
        /// Gets a data set from the database tables.
        /// </summary>
        /// <param name="tableNames">The list of table names in the xml 
        /// schema to export. If null, then all table names in the xml 
        /// schema will be exported.</param>
        /// <exception cref="NDbUnitException" />
        DataSet GetDataSetFromDb(StringCollection tableNames);


        /// <summary>
        /// Gets or sets the command time out.
        /// </summary>
        /// <value>The command time out.</value>
        int CommandTimeOut { get; set; }


        /// <summary>
        /// Executes the scripts.
        /// </summary>
        void ExecuteScripts();


        /// <summary>
        /// Gets the Script Manager.
        /// </summary>
        /// <value>The Script Manager.</value>
        ScriptManager Scripts { get; }

    }
}